Skip to content

[UI] Preserve SwiftUI sizing and replacement transitions - #92

Merged
NachoSoto merged 2 commits into
masterfrom
swiftui-image-content-mode-transitions
Sep 3, 2026
Merged

[UI] Preserve SwiftUI sizing and replacement transitions#92
NachoSoto merged 2 commits into
masterfrom
swiftui-image-content-mode-transitions

Conversation

@NachoSoto

Copy link
Copy Markdown
Owner

Summary

  • add explicit SwiftUI image sizing modes while preserving aspect-fit as the default
  • give each rendered image a stable SwiftUI identity so placeholder-to-source replacements run their existing opacity transition
  • cover the new sizing initializers in the retained-state test matrix

Motivation

WatchChess tournament cells need the legacy scaleToFill presentation without falling back to a UIViewRepresentable. The existing SwiftUI implementation also attached a transition without changing view identity, so replacing a placeholder with the final image did not actually insert a transitioning view.

Validation

  • Swift 6 iOS Simulator library build
  • iOS Simulator package test action
  • strict SwiftLint: 0 violations across 34 files

Comment thread AsyncImageView/AsyncSwiftUIImageView.swift Outdated
Comment thread AsyncImageView/AsyncSwiftUIImageView.swift Outdated
@NachoSoto
NachoSoto marked this pull request as ready for review September 3, 2026 18:53
@NachoSoto
NachoSoto merged commit 92bd7f1 into master Sep 3, 2026
2 checks passed
@NachoSoto
NachoSoto deleted the swiftui-image-content-mode-transitions branch September 3, 2026 18:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T18:57:14.580174Z 6e01b2e Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

https://github.com/NachoSoto/AsyncImageView/blob/6e01b2ec20c14b6488d2d006037bb69b154432f1/AsyncSwiftUIImageView.swift#L152
P2 Badge Add an actual stretch-to-fill mode

When .fill is selected for a non-square image in a differently shaped frame, aspectRatio(nil, contentMode: .fill) preserves the image's aspect ratio; it is SwiftUI's aspect-fill behavior and cannot reproduce stretch-to-bounds/UIImageView.ContentMode.scaleToFill. The image will instead extend beyond one frame dimension and either bleed or be cropped, so the legacy scale-to-fill use case described by this change still needs a distinct mode that omits the aspect-ratio modifier.


https://github.com/NachoSoto/AsyncImageView/blob/6e01b2ec20c14b6488d2d006037bb69b154432f1/AsyncSwiftUIImageView.swift#L153-L154
P2 Badge Base replacement animation on the incoming result

When a non-cache-hit image is currently displayed and the next result is a cache hit, changing the ID removes the old subtree using that old subtree's .easeOut transition; the incoming view's animation(nil) does not cancel the outgoing transition. The replacement can therefore still cross-fade or linger despite cache hits being intended to swap immediately, unlike AsyncImageView.updateImage; drive the whole replacement transaction from the incoming result or otherwise disable the outgoing animation for cached replacements.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant